import java.util.Scanner;

/**
 * @author yu
 * @date 2025年04月18日 9:43
 */
/*
public class _20250412_02 {
    public static int function(int n ,int[] a){
        */
/*//*
/只有一个数
        if(n==1) return a[0];*//*

        int res = 0;
        //有两个以上数字 和后面的进行对比
        for (int i = 0; i < n-1; i++) {
            res += a[i];
            if(a[i] > a[i+1]){
                res += a[i+1];
            }else {
                res += a[i]-1;
            }
        }
        res += n;
        return res;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        System.out.println(function(n,a));
        scanner.close();
    }
}
*/


public class _20250412_02 {
    // 根据a数组构建b数组
    private static int[] buildArrayB(int[] a) {
        int sum = 0;
        for (int num : a) {
            sum += num;
        }
        int[] b = new int[sum];
        int index = 0;
        for (int num : a) {
            for (int i = 1; i <= num; i++) {
                b[index++] = i;
            }
        }
        return b;
    }

    // 判断子数组是否是1 - len的排列
    private static boolean isPermutation(int[] subArray) {
        int len = subArray.length;
        boolean[] visited = new boolean[len + 1];
        for (int num : subArray) {
            //数字超过子数组长度或者已经被标记过,就不是排列
            if (num > len || visited[num]) {
                return false;
            }
            visited[num] = true;
        }
        return true;
    }

    public static int function(int n, int[] a) {
        int[] b = buildArrayB(a);
        int count = 0;
        int[] window = new int[0];
        for (int left = 0; left<b.length; left++) {
            for (int right = left; right < b.length; right++) {
                window = new int[right - left + 1];
                //将数组抄进widow
                System.arraycopy(b, left, window, 0, right - left + 1);
                if (isPermutation(window)) {
                    count++;
                }
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        System.out.println(function(n, a));
        scanner.close();
    }
}